﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace belov_test
{
    public partial class ChangePasswordForm : Form
    {
        private String m_oldPassword;
        private String m_newPassword;
        
        public ChangePasswordForm(String oldPassword)
        {
            InitializeComponent();

            m_oldPassword = oldPassword;
        }

        private void OnPasswordChange(object sender, EventArgs e)
        {
            String oldPassword = m_oldPassTextBox.Text.Trim();
           
            if (m_oldPassword != oldPassword)
            {
                MessageBox.Show("Текущий пароль не верный!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            String newPassword = m_newPassTextBox.Text.Trim();
            String newPasswordConf = m_newPassConfTextBox.Text.Trim();

            if (newPassword != newPasswordConf)
            {
                MessageBox.Show("Введенные пароли не совпадают!", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            m_newPassword = newPassword;

            Close();
        }

        private void OnCancel(object sender, EventArgs e)
        {
            Close();
        }

        public String NewPassword
        {
            get { return m_newPassword; }
            set { m_newPassword = value; }
        }

        private void OnChecked(object sender, EventArgs e)
        {
            m_oldPassTextBox.UseSystemPasswordChar = !m_showPasswordsCB.Checked;
            m_newPassTextBox.UseSystemPasswordChar = !m_showPasswordsCB.Checked;
            m_newPassConfTextBox.UseSystemPasswordChar = !m_showPasswordsCB.Checked;
        }
    }
}
